package edu.ar.modulo2.valentinis.persist.daoImpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import edu.ar.modulo2.valentinis.modelo.Cliente;
import edu.ar.modulo2.valentinis.modelo.Empleado;
import edu.ar.modulo2.valentinis.persist.ConnectionManager;
import edu.ar.modulo2.valentinis.persist.dao.IClienteDAO;

public class ClienteDAOJdbcImpl implements IClienteDAO{

	@Override
	public void save(Cliente enttity) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(Cliente enttity) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void delet(Cliente enttity) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Cliente> getAll() {

		Statement st = null;
		ResultSet rs = null;
		List<Cliente> list = new ArrayList<Cliente>();
		String sql = "SELECT * FROM Cliente";
		
		try {
			
			st = ConnectionManager.getInstance().getConnection().createStatement();
			rs = st.executeQuery(sql);
			
			while( rs.next() ) {
				
				Cliente per = new Cliente();
								
				per.setNroCliente( rs.getString("dni") );
				per.setRazonSocial( rs.getString("nombre") );
				
				list.add(per);				
			}
			
		} catch (SQLException e) {
			
			System.out.println("ERROR EN EL SATEMENT");
			e.printStackTrace();
		}
		
		return list;

	}

	@Override
	public Cliente getElemntById(Long id) {
		// TODO Auto-generated method stub
		return null;
	}
}
